import java.util.Scanner;

public class shijian {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int a=in.nextInt();
        int b=in.nextInt();
        int c=in.nextInt();
        b=b+c;
        int d,e;
        d=(b/60);
        e=b%60;
        a=a+d;
        if(a>23){
            a=a-24;
        }
        System.out.println(a + " " + e);
    }
}
